﻿namespace HuaWei.DAL.SqlClient
{
    using HuaWei;
    using HuaWei.DAI;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.ServiceModel;

    public class CWCFDataAccess : IDataAccess
    {

        private ConcurrentProcessType concurrentProcessType;
        private IWCFService iwcfservice;
        private string str;

        private string str1;

        private string str2;

        private string str3;

        public CWCFDataAccess()
        {
            this.iwcfservice = null;
        }

        public void BeginTrans()
        {
        }

        public void CloseDatabase()
        {
        }

        public void Commit()
        {
        }

        public DataSet ExecuteDataSet(string exeStr, DbParameter[] outParams)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, DbParameter[] outParams, string TableName)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, outParams, TableName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType, DbParameter[] inParams)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType, inParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType, string TableName)
        {
            DataSet set;
            try
            {
                this.method().Login(this.ProductNo, "", "");
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType, TableName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType, DbParameter[] inParams, DbParameter[] outParams)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType, inParams, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType, DbParameter[] inParams, string TableName)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType, inParams, TableName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public DataSet ExecuteDataSet(string exeStr, CommandType cmdType, DbParameter[] inParams, DbParameter[] outParams, string TableName)
        {
            DataSet set;
            try
            {
                set = this.method().ExecuteDataSet(this.ProductNo, exeStr, cmdType, inParams, outParams, TableName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return set;
        }

        public bool ExecuteNonQuery(ArrayList sqls, CommandType cmdType)
        {
            bool flag;
            try
            {
                flag = this.method().ExecuteNonQuery(this.ProductNo, sqls, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return flag;
        }

        public bool ExecuteNonQuery(Hashtable sqls, CommandType cmdType)
        {
            bool flag;
            try
            {
                flag = this.method().ExecuteNonQuery(this.ProductNo, sqls, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return flag;
        }

        public int ExecuteNonQuery(string proName, DbParameter[] outParams)
        {
            int num;
            try
            {
                num = this.method().ExecuteNonQuery(this.ProductNo, proName, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return num;
        }

        public int ExecuteNonQuery(string exeStr, CommandType cmdType)
        {
            int num;
            try
            {
                num = this.method().ExecuteNonQuery(this.ProductNo, exeStr, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return num;
        }

        public int ExecuteNonQuery(string exeStr, CommandType cmdType, DbParameter[] inParams)
        {
            int num;
            try
            {
                num = this.method().ExecuteNonQuery(this.ProductNo, exeStr, cmdType, inParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return num;
        }

        public int ExecuteNonQuery(string exeStr, CommandType cmdType, DbParameter[] inParams, DbParameter[] outParams)
        {
            int num;
            try
            {
                num = this.method().ExecuteNonQuery(this.ProductNo, exeStr, cmdType, inParams, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return num;
        }

        public object ExecuteReader(string exeStr, DbParameter[] outParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteReader(this.ProductNo, exeStr, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteReader(string exeStr, CommandType cmdType)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteReader(this.ProductNo, exeStr, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteReader(string exeStr, CommandType cmdType, DbParameter[] inParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteReader(this.ProductNo, exeStr, cmdType, inParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteReader(string exeStr, CommandType cmdType, DbParameter[] inParams, DbParameter[] outParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteReader(this.ProductNo, exeStr, cmdType, inParams, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteScalar(string exeStr, DbParameter[] outParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteScalar(this.ProductNo, exeStr, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteScalar(string exeStr, CommandType cmdType)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteScalar(this.ProductNo, exeStr, cmdType);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteScalar(string exeStr, CommandType cmdType, DbParameter[] inParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteScalar(this.ProductNo, exeStr, cmdType, inParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public object ExecuteScalar(string exeStr, CommandType cmdType, DbParameter[] inParams, DbParameter[] outParams)
        {
            object obj2;
            try
            {
                obj2 = this.method().ExecuteScalar(this.ProductNo, exeStr, cmdType, inParams, outParams);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return obj2;
        }

        public DataSet GetDs(DataSet dsSource, string invokeCode, string param)
        {
            return this.method().GetDs(this.ProductNo, dsSource, invokeCode, param);
        }

        public string Invoke(DataSet dsSource, string invokeCode, string param)
        {
            return this.method().Invoke(this.ProductNo, dsSource, invokeCode, param);
        }

        private IWCFService method()
        {
            try
            {
                if ((this.iwcfservice == null) && !string.IsNullOrEmpty(this.ConnectionString))
                {
                    WSHttpBinding binding = new WSHttpBinding(SecurityMode.None);
                    binding.MaxReceivedMessageSize = 0x7fffffffL;
                    binding.MaxBufferPoolSize = 0x7fffffffL;
                    binding.SendTimeout = new TimeSpan(0, 0x12, 0);
                    binding.ReceiveTimeout = new TimeSpan(0x12, 0x12, 0);
                    IWCFService service = ChannelFactory<IWCFService>.CreateChannel(binding, new EndpointAddress(this.ConnectionString));
                    this.iwcfservice = service;
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return this.iwcfservice;
        }

        public void OpenDatabase()
        {
        }

        public void RollBack()
        {
        }

        public string SyncData(DataSet dsSource)
        {
            return this.method().SyncData(this.ProductNo, dsSource);
        }

        public void Update(DataTable table)
        {
            try
            {
                this.method().Update(this.ProductNo, table);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }

        public void Update(DataSet dsUpdate, [Optional, DefaultParameterValue(true)] bool writeLog)
        {
            try
            {
                this.method().Update(this.ProductNo, dsUpdate, writeLog);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }

        public void Update(DataSet dsUpdate, string strTableName)
        {
            try
            {
                this.method().Update(this.ProductNo, dsUpdate, strTableName);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }

        public void Update(DataSet dsChanges, Dictionary<DataRowState, string[]> updateIndex, params string[] exeStr)
        {
            try
            {
                this.method().Update(this.ProductNo, dsChanges, updateIndex, exeStr);
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }

        public ConcurrentProcessType CCProcessType
        {
    
            get
            {
                return this.concurrentProcessType;
            }
    
            set
            {
                this.concurrentProcessType = value;
            }
        }

        public string ConnectionString
        {
            get
            {
                return this.str;
            }
            set
            {
                this.str = value;
            }
        }

        public ConnectionState ConnState
        {
            get
            {
                return ConnectionState.Open;
            }
        }

        public string DBType
        {
    
            get
            {
                return this.str1;
            }
    
            set
            {
                this.str1 = value;
            }
        }

        public string ProductNo
        {
    
            get
            {
                return this.str3;
            }
    
            set
            {
                this.str3 = value;
            }
        }

        public string ServerDBType
        {
    
            get
            {
                return this.str2;
            }
    
            set
            {
                this.str2 = value;
            }
        }
    }
}

